package io.demo.message.domain.proto;


import io.demo.message.domain.proto.Ethnic.SkinColor;

public class EthnicMessageConverter
    implements MessageConverter<io.demo.message.domain.Ethnic, Ethnic> {

  @Override
  public io.demo.message.domain.proto.Ethnic toMessage(io.demo.message.domain.Ethnic pojo) {
    return io.demo.message.domain.proto.Ethnic.newBuilder()
        .setId(pojo.getId())
        .setName(pojo.getName())
        .setPopulation(pojo.getPopulation())
        .setSkinColor(SkinColor.valueOf(pojo.getSkinColor().name()))
        .build();
  }

  @Override
  public io.demo.message.domain.Ethnic fromMessage(Ethnic message) {
    return io.demo.message.domain.Ethnic.builder()
        .id(message.getId())
        .name(message.getName())
        .population(message.getPopulation())
        .skinColor(io.demo.message.domain.SkinColor.valueOf(message.getSkinColor().name()))
        .build();
  }
}
